<?php
/*
 * @Author: CHINAKAIYUAN<sunkaiyuan@namenode.cn>
 * @Date: 2022-02-03 00:33:05
 * @LastEditTime: 2022-09-26 13:09:14
 * @LastEditors: CHINAKAIYUAN
 * @Description: 
 */

namespace App\Models;


class TemporaryToken extends BaseModel
    {
    public $timestamps = true;
    public $table = "sys_temporary_token";
    protected $guarded = [];
    protected $appends = ['isTimeOut'];

    public function getIsTimeOutAttribute()
        {
        $createtime = strtotime($this->updated_at);
        $nowtime    = time();
        //expiresin=0  永不过期

        return $this->expiresin == 0 ? false : ($nowtime - $createtime) > $this->expiresin;
        }
    public function user()
        {
        return $this->belongsTo(User::class, "user_id", "employee_id");
        }
    public function sockets()
        {
        return $this->hasMany(TokenSocket::class, "token_id");
        }
    }
